<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="对账批次">
        <el-input v-model="queryParams.checkBatchNo" placeholder="审批人"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="handleQuery">查询</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="success"
          icon="el-icon-edit"
          size="mini"
          @click="handleUpdate"
          v-hasPermi="['financing:clearing:edit']"
        >确认结算</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['financing:clearing:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="clearingList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center"/>
      <el-table-column label="对账批次" align="center" prop="checkBatchNo" />
      <el-table-column label="商户名称" align="center" prop="businessName" />
      <el-table-column label="结算金额" align="center" prop="amount"/>
      <el-table-column label="交易日期" align="center" prop="tradeDateZf" />

    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

  </div>
</template>

<script>
import { listClearing,updateStatus } from "@/api/finance/clearing";

export default {
  name: "clearing",
  components: {
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 楼盘信息表格数据
      clearingList: [
      ],
      // 弹出层标题
      title: "",
      // 查询参数
      queryParams: {
        checkBatchNo:'',
        pageNum: 1,
        pageSize: 10,
        total:0
      },

    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询楼盘信息列表 */
    getList() {
      this.loading = true;
      listClearing(this.queryParams).then(response => {
        this.clearingList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /**结算按钮**/
    handleUpdate(){
      updateStatus(this.ids).then(response=>{
        this.getList();
      })
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('finance/clearing/export', {
        ...this.queryParams
      }, `finance_clearing.xlsx`)
    }
  }
};
</script>
